import random

def lastmove( move ):
    return    

def make_move(userchoice):
    global sequences, computerwins, userwins

    userchoice = userchoice.lower()

    if userchoice not in sequences or len(sequences[userchoice]) < 3:
        computer_choices = ["剪刀", "石头", "布"]
        computer_choice = random.choice(computer_choices)
    else:
        # 获取用户出拳历史
        user_history = [choice for choice, count in sequences[userchoice].items() for _ in range(count)]
        # 获取用户出拳之后电脑可能出拳的历史
        computer_choices = []
        for i in range(len(user_history)-2):
            if user_history[i] == userchoice:
                computer_choices.append(user_history[i+1])
        if computer_choices:
            # 按照出现次数选择出拳
            computer_choice = max(set(computer_choices), key=computer_choices.count)
        else:
            # 如果没有匹配的历史记录，则随机选择
            computer_choices = ["剪刀", "石头", "布"]
            computer_choice = random.choice(computer_choices)

    if userchoice not in sequences:
        sequences[userchoice] = {}
    if computer_choice not in sequences[userchoice]:
        sequences[userchoice][computer_choice] = 1
    else:
        sequences[userchoice][computer_choice] += 1

    return computer_choice
